#include "../types.h"

#define SCE_UTILITY_STATUS_NONE         0
#define SCE_UTILITY_STATUS_INITIALIZE   1
#define SCE_UTILITY_STATUS_RUNNING      2
#define SCE_UTILITY_STATUS_FINISHED     3
#define SCE_UTILITY_STATUS_SHUTDOWN     4

u8 utilityState = 0;

void __sceUtilityWinInitStart()
{
    utilityState = SCE_UTILITY_STATUS_INITIALIZE;
}

void __sceUtilityWinShutdownStart()
{
    utilityState = SCE_UTILITY_STATUS_SHUTDOWN;
}

u8 __sceUtilityWinDoUpdate()
{
    if (utilityState == SCE_UTILITY_STATUS_INITIALIZE) {
        utilityState = SCE_UTILITY_STATUS_RUNNING;
        return 0;
    }
    else if (utilityState == SCE_UTILITY_STATUS_RUNNING)
        return 1;
    else
        return 0;
}

void __sceUtilityWinFinish()
{
    utilityState = SCE_UTILITY_STATUS_FINISHED;
}

u8 __sceUtilityWinGetStatus()
{
    u8 ret = utilityState;
    if (utilityState == SCE_UTILITY_STATUS_SHUTDOWN)
        utilityState = SCE_UTILITY_STATUS_NONE;
    else if (utilityState == SCE_UTILITY_STATUS_INITIALIZE)
        utilityState = SCE_UTILITY_STATUS_RUNNING;
    return ret;
}

